/**
 * Copyright 2008-2009 HAN.BIFANG
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package han.bashe.common.schema;

import han.bashe.common.entity.BifangEntityConstants;
import han.bashe.common.jms.JmsBinding;
import han.bashe.common.jms.JmsBindingWrapper;
import han.bashe.common.jms.NormalJms;
import v1.query.web.bifang.han.BusBindingDocument.BusBinding;
import v1.query.web.bifang.han.ServiceBusDocument.ServiceBus;

/**
 * @Author Kent
 */
public class ServiceBusUtil {
	
	public static JmsBindingWrapper getJmsBinding(ServiceBus bus){
		JmsBindingWrapper jw = null;
		for(BusBinding b :bus.getBusBindingList()){
			if(b.getName().equals(BifangEntityConstants.BUS_BINDING_JMS)){
				 jw = new JmsBindingWrapper();
				JmsBinding jb = new JmsBinding();
				jb.setJmsType(b.getBinding().getJmsBinding().getJmsType());
				jb.setServer(b.getBinding().getJmsBinding().getServer());
				jb.setServerVersion(b.getBinding().getJmsBinding().getServerVersion());
				NormalJms info = new NormalJms();
				info.setDestinationJndi(b.getBinding().getJmsBinding().getInfo().getNormalJms().getDestinationJndi());
				info.setFactoryUrl(b.getBinding().getJmsBinding().getInfo().getNormalJms().getFactoryUrl());
				info.setServerUrl(b.getBinding().getJmsBinding().getInfo().getNormalJms().getServerUrl());
				jw.setJmsBinding(jb);
				jw.setInfo(info);
				break;
			}
		}
		return jw;
	}

}
